/**
 * Created by Administrator on 2017/12/19.
 */
import cookie from "js-cookie";
import { Toast } from 'antd-mobile';
import { routerRedux } from 'dva/router';
import { memberInfo } from '../../services/organization';

export default {
  namespace: 'dangyuanlists',
  state: {
    menberInfo: [],
  },
  subscriptions: {
    setup({dispatch, history}) {
      history.listen(({pathname, query}) => {
        /*if (pathname === '/work/zzadminister/dangyuanlist') {
          dispatch({
            type: 'fetch',
          })
        }*/
      })
    }
  },

  effects: {
    * fetch({payload}, {call, put, select}) {
      // let newsObject = sessionStorage.getItem('userdata');
      //newsObject = JSON.parse(newsObject);
      const data = yield call(memberInfo, payload);
      if (data.data.code == 200) {
        yield put({
          type: 'success',
          payload: {
            menberInfo:data.data.ret
          }
        });
      }
      else {
        Toast.success('查询失败！', 1);
      }
    },

    * fetchAdmin({payload}, {call, put, select}) {
      // let newsObject = sessionStorage.getItem('userdata');
      //newsObject = JSON.parse(newsObject);
      const data = yield call(memberInfo, {code: "U707517560978935987", relation: ["extend", "org", "infos"]});
      if (data.data.code == 200) {
        yield put({
          type: 'success',
          payload: {
            menberInfo:data.data.ret
          }
        });
      }
      else {
        Toast.success('查询失败！', 1);
      }
    }
  },
  reducers: {
    success(state, action){
      return {...state, ...action.payload};
    }
  }
};
